-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make sys.executable work with script bootstrap #2409
fix: make sys.executable work with script bootstrap #2409
Conversation
bd85a4c
to
d68262c
Compare
FYI, I am curious if the next version of this and #2359 combined could make it easy to have a |
3ea4bcc
to
287b7bf
Compare
287b7bf
to
028f9d1
Compare
I'm not sure I follow. With this PR, each binary will have its own venv, so an editor could be pointed to that directly. Do you mean something like, you do a one time setup to point your editor to some "well known path", and then run |
I think you understood it. I was thinking that you could do either:
or tell VSCode or similar that the Python interpreter for We could also symlink it to a well known location using https://github.com/buildbuddy-io/bazel_env.bzl |
Ok, ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed most, still have 1 or 2 left. Thanks!
…o fix.script.boot.sys.exe
Co-authored-by: Ignas Anikevicius <[email protected]>
Co-authored-by: Ignas Anikevicius <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, LGTM in general.
…o fix.script.boot.sys.exe
❤️ |
hi @rickeylev this doesn't seem to be working, Not sure if it is my system or what.
|
Hmm actually it fails on WSL Ubuntu and is fine on a regular Linux Machine. Says a broken symbolic link
|
When
--bootstrap_impl=script
is used,PYTHONPATH
is no longer used to set the importpaths, which means subprocesses no longer inherit the Bazel paths. This is generally a
good thing, but breaks when
sys.executable
is used to directly invoke the interpreter.Such an invocation assumes the interpreter will have the same packages available and works
with the system_python bootstrap.
To fix, have the script bootstrap use a basic virtual env. This allows it to intercept
interpreter startup even when the Bazel executable isn't invoked. Under the hood, there's
two pieces to make this work. The first is a binary uses
declare_symlink()
to write arelative-path based symlink that points to the underlying Python interpreter. The second
piece is a site init hook (triggered by a
.pth
file using animport
line) performssys.path setup as part of site (
import site
) initialization.Fixes #2169